package com.xnyzc.lhy.mis.controller.cmsapi.agreement;

import com.xnyzc.lhy.common.entity.Rv;
import com.xnyzc.lhy.mis.entity.param.cms.agreement.AgreementParam;
import com.xnyzc.lhy.mis.service.cms.agreement.AgreementService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 协议相关
 *
 * @Author: wangshuo
 * @Date: 2019-09-09 14:11
 */
@RestController
@RequestMapping("/cmsapi/agreement")
public class AgreementController {

    @Autowired
    private AgreementService agreementService;

    /**
     * 用户协议
     *
     * @return
     */
    @ApiOperation(value = "用户协议", notes = "用户协议")
    @GetMapping(value = "/getUserAgreement")
    public Rv getUserAgreement(
    ) {
        return Rv.wrap(agreementService.getUserAgreement());
    }

    /**
     * 编辑用户协议
     *
     * @return
     */
    @ApiOperation(value = "编辑用户协议", notes = "编辑用户协议")
    @PostMapping(value = "/getUpdateUserAgreement")
    public Rv getUpdateUserAgreement(
            @ApiParam(name = "agreementParam", value = "接入传参") @RequestBody AgreementParam agreementParam
    ) {
        return Rv.wrap(agreementService.getUpdateUserAgreement(agreementParam));
    }

    /**
     * 充值协议
     *
     * @return
     */
    @ApiOperation(value = "充值协议", notes = "充值协议")
    @GetMapping(value = "/getRechargeAgreement")
    public Rv getRechargeAgreement() {
        return Rv.wrap(agreementService.getRechargeAgreement());
    }

    /**
     * 编辑充值协议
     *
     * @return
     */
    @ApiOperation(value = "编辑充值协议", notes = "编辑充值协议")
    @PostMapping(value = "/getUpdateRechargeAgreement")
    public Rv getUpdateRechargeAgreement(
            @ApiParam(name = "agreementParam", value = "接入传参") @RequestBody AgreementParam agreementParam
    ) {
        return Rv.wrap(agreementService.getUpdateRechargeAgreement(agreementParam));
    }

    /**
     * 根据类型(type)查询一个协议, 比如'用户协议'
     *
     * @return
     */
    @ApiOperation(value = "根据类型(type)查询一个协议, 比如'用户协议'", notes = "根据类型(type)查询一个协议, 比如'用户协议'")
    @GetMapping(value = "/getAgreementByType")
    public Rv getAgreementByType(Integer type) {
        return agreementService.getAgreementByType(type);
    }


    /**
     * 根据类型(type)修改一个协议, 比如'用户协议'
     *
     * @return
     */
    @ApiOperation(value = "根据类型(type)修改一个协议, 比如'用户协议'", notes = "根据类型(type)修改一个协议, 比如'用户协议'")
    @PostMapping(value = "/updateAgreementByType")
    public Rv updateAgreementByType(@ApiParam(name = "agreementParam", value = "修改传参") @RequestBody AgreementParam param) {
        return agreementService.updateAgreementByType(param);
    }
}
